// package com.example.mallcommon.utils;
//
// import cn.hutool.http.HttpStatus;
// import cn.hutool.json.JSON;
// import com.sun.org.apache.bcel.internal.classfile.Code;
// import reactor.core.publisher.Mono;
//
// import java.nio.charset.StandardCharsets;
//
// public class FilterUtil {
//
//     public static Mono<Void> failResponse(ServerWebExchange exchange, Code code, String msg){
//         ServerHttpResponse response = exchange.getResponse();
//         Result resp = Result.of(code,msg);
//         byte[] bits = JSON.toJSONString(resp).getBytes(StandardCharsets.UTF_8);
//         DataBuffer buffer = response.bufferFactory().wrap(bits);
//         response.setStatusCode(HttpStatus.UNAUTHORIZED);
//         //指定编码，否则在浏览器中会中文乱码
//         response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
//         return response.writeWith(Mono.just(buffer));
//     }
// }
